//
//  TopicContentTableViewCell.swift
//  HoneyBee
//
//  Created by Smith_Yang on 2018/5/30.
//  Copyright © 2018 point. All rights reserved.
//

import UIKit


class TopicContentTableViewCell: UITableViewCell {

    @IBOutlet weak var richView: RichEditorView!
    
    public var changeHeight: ((CGFloat) -> Void)?

    override func awakeFromNib() {
        super.awakeFromNib()
        
        selectionStyle = .none

        // Initialization code
        richView.delegate = self;
        richView.isScrollEnabled = false
        richView.backgroundColor = UIColor.white
        richView.isEditingEnabled = false
        richView.html = "<div style=\"text-align: center;\"><span style=\"-webkit-text-size-adjust: 100%;\">拉到你身上没有一点瑕疵不重要</span></div><div style=\"text-align: center;\"><span style=\"-webkit-text-size-adjust: 100%;\">太可怜了</span><img src=\"http://www.w3school.com.cn/i/eg_tulip.jpg\" />"
        
        
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    public func configModel(model:TopicDetailModel) {
        
        richView.html = model.article
        
    }

    
}

extension TopicContentTableViewCell: RichEditorDelegate {
    func richEditor(_ editor: RichEditorView, heightDidChange height: Int) {
        if let callback = changeHeight {
            callback (CGFloat(height))
        }
        
    }
    
}

